home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-02 | 9.7 KB | 330 lines | [TEXT/MPS ] |
- /*
- File: Demo3D.cp
-
- Contains: 3D drawing demo program
-
- Written by: Jamie Osborne
-
- Copyright: © 1992-1993 by Apple Computer, Inc.
-
- */
-
- #include "UDemo3D.h"
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __UFAILURE__
- #include <UFailure.h>
- #endif
-
- #ifndef __UVIEWSERVER__
- #include <UViewServer.h>
- #endif
-
-
- #ifndef __UMACAPPUTILITIES__
- #include <UMacAppUtilities.h>
- #endif
-
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
-
- #ifndef __UWINDOW__
- #include <UWindow.h>
- #endif
-
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __STDLIB__
- #include <StdLib.h>
- #endif
-
- #ifndef __UCONTROL__
- #include <UControl.h>
- #endif
-
- #include "U3DDrawing.h"
-
- //----------------------------------------------------------------------------------------
- // Constants
- const short c3DDrawingWind = 1001;
- const short c3DDrawingProcWind = 1002;
-
- const short kModalDialog = 1010;
- const short kBadWindow = 1011;
-
- const short kStrings = 2000;
-
- //========================================================================================
- // CLASS TTestApplication
- //========================================================================================
-
-
- //----------------------------------------------------------------------------------------
- // TTestApplication::ITestApplication:
- //----------------------------------------------------------------------------------------
- #pragma segment AInit
-
- pascal void TTestApplication::ITestApplication()
-
- {
- IApplication(kFileType, kSignature);
-
- macroDontDeadStrip(TDemoWindow);
-
- fLaunchWithNewDocument = FALSE; // Suppress the creation of a new document at launch
-
- this->DoMenuCommand(c3DDrawingWind); // Show the View window
-
- } // TTestApplication::ITestApplication
-
- //----------------------------------------------------------------------------------------
- // TTestApplication::DoMakeDocument:
- //----------------------------------------------------------------------------------------
- #pragma segment AOpen
-
- pascal TDocument* TTestApplication::DoMakeDocument(CommandNumber /*itsCommandNumber*/,
- TFile* /*itsFile*/ )// override
-
- {
- return NULL;
- } // TTestApplication::DoMakeDocument
-
-
- //----------------------------------------------------------------------------------------
- // TTestApplication::DoMenuCommand:
- //----------------------------------------------------------------------------------------
- #pragma segment ASelCommand
-
- pascal void TTestApplication::DoMenuCommand(CommandNumber aCommandNumber)// override
-
-
- {
- switch (aCommandNumber)
- {
- case c3DDrawingWind:
- MakeDrawingWind();
- break;
- case c3DDrawingProcWind:
- MakeDrawingProcWind();
- break;
- default:
- inherited::DoMenuCommand(aCommandNumber);
- break;
- }
- } // TTestApplication::DoMenuCommand
-
-
- //----------------------------------------------------------------------------------------
- // TTestApplication::DoSetupMenus:
- //----------------------------------------------------------------------------------------
- #pragma segment ARes
-
- pascal void TTestApplication::DoSetupMenus()// override
-
- {
- inherited::DoSetupMenus();
-
- Enable(c3DDrawingWind, TRUE);
- Enable(c3DDrawingProcWind, TRUE);
-
- } // TTestApplication::DoSetupMenus
-
-
- //----------------------------------------------------------------------------------------
- // TTestApplication::MakeDrawingWind:
- //----------------------------------------------------------------------------------------
- pascal void TTestApplication::MakeDrawingWind()
-
- {
- TWindow * aWindow;
-
-
- FailNIL(aWindow = gViewServer->NewTemplateWindow(c3DDrawingWind, NULL));
- aWindow->Open();
- } // TTestApplication::MakeTemplateViews
-
-
- //----------------------------------------------------------------------------------------
- // TTestApplication::MakeDrawingProcWind:
- //----------------------------------------------------------------------------------------
- #pragma segment ASelCommand
-
- pascal void TTestApplication::MakeDrawingProcWind()
-
- {
- TWindow *aWindow;
- VPoint itsLocation, itsSize;
-
- FailNIL(aWindow = gViewServer->NewTemplateWindow(c3DDrawingProcWind, NULL));
-
- TStaticText *aStaticText = new TStaticText;
- itsLocation = VPoint(15, 13);
- itsSize = VPoint(362, 16);
- aStaticText->IStaticText(aWindow, itsLocation, itsSize, sizeVariable, sizeVariable, kStrings, 1);
-
- TStaticText *aStaticText2 = new TStaticText;
- itsLocation = VPoint(278, 188);
- itsSize = VPoint(188, 48);
- aStaticText2->IStaticText(aWindow, itsLocation, itsSize, sizeVariable, sizeVariable, kStrings, 2);
-
- TStaticText *aStaticText3 = new TStaticText;
- itsLocation = VPoint(269, 53);
- itsSize = VPoint(116, 16);
- aStaticText3->IStaticText(aWindow, itsLocation, itsSize, sizeVariable, sizeVariable, kStrings, 3);
-
- TCluster *aCluster = new TCluster;
- itsLocation = VPoint(266, 120);
- itsSize = VPoint(199, 53);
- aCluster->ICluster(aWindow, itsLocation, itsSize, sizeVariable, sizeVariable, kNoResource, 0);
- aCluster->SetLabel("A Cluster!", kRedraw);
-
- itsSize = VPoint(78, 18);
- T3DRadio *aRadio1 = new T3DRadio;
- itsLocation = VPoint(10, 13);
- aRadio1->I3DRadio(aCluster, itsLocation, itsSize, sizeVariable, sizeVariable, "Radio 1", TRUE);
-
- T3DRadio *aRadio2 = new T3DRadio;
- itsLocation = VPoint(10, 31);
- aRadio2->I3DRadio(aCluster, itsLocation, itsSize, sizeVariable, sizeVariable, "Radio 2" , FALSE);
-
- T3DRadio *aRadio3 = new T3DRadio;
- itsLocation = VPoint(107, 13);
- aRadio3->I3DRadio(aCluster, itsLocation, itsSize, sizeVariable, sizeVariable, "Disabled", FALSE);
-
- T3DRadio *aRadio4 = new T3DRadio;
- itsLocation = VPoint(107, 31);
- aRadio4->I3DRadio(aCluster, itsLocation, itsSize, sizeVariable, sizeVariable, "Disabled", FALSE);
- aRadio4->DimState(TRUE, FALSE);
- aRadio4->SetEnable(FALSE);
-
- T3DCheckBox *aCheckBox = new T3DCheckBox;
- itsLocation = VPoint(26, 203);
- itsSize = VPoint(154, 18);
- aCheckBox->I3DCheckBox(aWindow, itsLocation, itsSize, sizeVariable, sizeVariable, "Enabled Check Box", FALSE);
-
- T3DCheckBox *aCheckBox2 = new T3DCheckBox;
- itsLocation = VPoint(26, 218);
- itsSize = VPoint(154, 28);
- aCheckBox2->I3DCheckBox(aWindow, itsLocation, itsSize, sizeVariable, sizeVariable, "Disabled Check Box", FALSE);
- aCheckBox2->DimState(TRUE, FALSE);
- aCheckBox2->SetEnable(FALSE);
-
- T3DButton *aButton = new T3DButton;
- itsLocation = VPoint(374, 244);
- itsSize = VPoint(82, 20);
- aButton->I3DButton(aWindow, itsLocation, itsSize, sizeVariable, sizeVariable, "Show Me");
- aButton->fIdentifier = 'BDBn';
- aButton->SetHilitedTextColor(CRGBColor(65535, 9109, 2210));
-
- T3DButton *aButton2 = new T3DButton;
- itsLocation = VPoint(280, 244);
- itsSize = VPoint(82, 20);
- aButton2->I3DButton(aWindow, itsLocation, itsSize, sizeVariable, sizeVariable, "Disabled");
- aButton2->DimState(TRUE, FALSE);
- aButton2->SetEnable(FALSE);
-
- T3DIconButton *anIcon = new T3DIconButton;
- itsLocation = VPoint(36, 76);
- itsSize = VPoint(26, 26);
- anIcon->I3DIconButton(aWindow,itsLocation, itsSize, sizeFixed, sizeFixed, 16, 1002, kButtonMode, FALSE);
- anIcon->fIdentifier = 'IBn1';
-
- T3DIconButton *anIcon2 = new T3DIconButton;
- itsLocation = VPoint(36, 121);
- itsSize = VPoint(26, 26);
- anIcon2->I3DIconButton(aWindow,itsLocation, itsSize, sizeFixed, sizeFixed, 16, 1002, kButtonMode, FALSE);
- anIcon2->DimState(TRUE, FALSE);
- anIcon2->SetEnable(FALSE);
-
- /* Took this out because of a compiler bug that couldn't handle this many register vars
- TView *aView = new TView;
- itsLocation = VPoint(246, 54);
- itsSize = VPoint(2, 210);
- aView->IView(NULL,aWindow,itsLocation, itsSize, sizeFixed, sizeFixed);
-
- T3DLineLeftAdorner *aLineAdorner = new T3DLineLeftAdorner;
- aLineAdorner->I3DLineLeftAdorner(TRUE);
- aView->AddAdorner(aLineAdorner, kAdornLast, TRUE);
- */
-
- TEditText *anEditText = new TEditText;
- itsLocation = VPoint(269, 69);
- itsSize = VPoint(199, 22);
- anEditText->IEditText(aWindow, itsLocation, itsSize, 255);
- anEditText->SetText("Edit Text", kDontRedraw);
- anEditText->DeleteAdornerByID(kFrameAdorner, TRUE); // We make our own frame
-
- TWhiteBackgroundAdorner *back = new TWhiteBackgroundAdorner;
- back->IWhiteBackgroundAdorner(TRUE);
-
- T3DFrameAdorner *frame = new T3DFrameAdorner;
- frame->I3DFrameAdorner(TRUE);
-
- anEditText->AddAdorner(back, kAdornFirst, TRUE);
- anEditText->AddAdorner(frame, kAdornLast, TRUE);
-
- TControl *aControl = new TControl;
- itsLocation = VPoint(93, 68);
- itsSize = VPoint(134, 90);
- aControl->IControl(aWindow,itsLocation, itsSize, sizeFixed, sizeFixed);
-
- TWhiteBackgroundAdorner *back2 = new TWhiteBackgroundAdorner;
- back2->IWhiteBackgroundAdorner(TRUE);
-
- T3DFrameAdorner *frame2 = new T3DFrameAdorner;
- frame2->I3DFrameAdorner(TRUE);
- aControl->AddAdorner(back2, kAdornFirst, TRUE);
- aControl->AddAdorner(frame2, kAdornLast, TRUE);
-
- TextStyle style;
- GetPortTextStyle(style);
- itsLocation = VPoint(2,2);
- itsSize = VPoint(115, 86);
- TScroller *scroller = new TScroller;
- scroller->IScroller(aControl, itsLocation, itsSize, sizeRelSuperView, sizeRelSuperView,
- VPoint(86, 86), FALSE, TRUE);
-
- TTextListView *aTextListView = new TTextListView;
- aTextListView->ITextListView(NULL, scroller, itsLocation, itsSize, sizeSuperView,
- sizeSuperView, 2, 16, 0, FALSE, FALSE, 2, 2, TRUE, style);
-
-
- aWindow->Open();
- } // TTestApplication::MakeProcedureViews
-
-
- pascal void TDemoWindow::DoEvent(EventNumber eventNumber,
- TEventHandler* source,
- TEvent* event)
- {
- switch(eventNumber)
- {
- case mButtonHit:
- if (source == this->FindSubView('BDBn'))
- {
- TWindow *aWindow;
- FailNIL(aWindow = gViewServer->NewTemplateWindow(kBadWindow, NULL));
- aWindow->Open();
- }
- break;
- case mIconButtonHit:
- if (source == this->FindSubView('IBn1'))
- {
- TWindow *aWindow;
- FailNIL(aWindow = gViewServer->NewTemplateWindow(kModalDialog, NULL));
- IDType dismisser = aWindow->PoseModally();
- if (dismisser == 'ok ')
- aWindow->CloseAndFree();
- }
- break;
- default:
- inherited::DoEvent(eventNumber, source, event);
- }
- }